from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QLineEdit,QTextEdit,QVBoxLayout
from PyQt5.QtWidgets import QPushButton,QHBoxLayout,QFormLayout,QMessageBox,QInputDialog,QColorDialog
from PyQt5.QtGui import QIcon,QPixmap
import sys
def click_user():
    result=QInputDialog.getText(window, '输入对话框', '请输入内容:')
    if result[1]:  # result[1] is True if the user clicked OK
        print("输入内容:", result[0])
def color():
    color = QColorDialog.getColor()
    if color.isValid():
        print("选择的颜色:", color.name())


if __name__ == "__main__":
    # 创建QApplication对象
    app=QApplication(sys.argv)
    #创建窗口
    window=QWidget()
    #命名窗口
    window.setWindowTitle("对话框")
    #指定图标
    window.setWindowIcon(QIcon("gege.png"))
    #设置窗口大小
    window.resize(1000, 800)
    #——————————————————————————————————————组件初始化
    root_layout = QHBoxLayout(window)
    btn=QPushButton("创建对话框")
    btn.clicked.connect(color)
    root_layout.addWidget(btn)
    # window.setLayout(root_layout)

    #_____________________________________
    #显示窗口
    window.show()
    #鼠标悬浮文字
    window.setToolTip("你好")
    #结束
    sys.exit(app.exec_())
    